package com.sharer.last.controller;

import com.sharer.last.base.constant.CommonConstant;
import com.sharer.last.base.model.R;
import com.sharer.last.service.OssFileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 文件注释地方
 *
 * @ClassName OssFileAdminController
 * @Author wangjin
 * @Date 2023/07/10/16:04
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.BLOG_ADMIN_API + "/oss")
public class OssFileAdminController {
    @Resource
    private OssFileService ossFileService;

    /**
     * 文件上传接口
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public R<String> upload(@RequestPart("file") MultipartFile file){
        String imgFileStr = ossFileService.upload(file);
        return R.success(imgFileStr);
    }
}
